package com.pengshun.modules.api.quartz.controller;

import com.pengshun.modules.api.quartz.service.QuartzService;
import com.pengshun.modules.common.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author luoligang
 * @create 2021/1/25
 */

//@EnableScheduling
//@RequiredArgsConstructor
//@Component


@RestController
@RequiredArgsConstructor
@Api(tags = "手动维护煤炭价格数据")
@RequestMapping("/api/coal/statisticals")
@ApiIgnore
public class QuartzController {

    private  final QuartzService quartzService;

//    @Scheduled(cron="0 * * * * ?")
//    public void coalRecordQuartz() throws Exception {
//
//        quartzService.updateCoalStatistical();
//    }


    @ApiImplicitParam(name = "coalId", value = "商户煤炭id", dataType = "int", required = true, paramType = "query")
    @ApiOperation(value = "根据煤炭id维护环比数据")
    @PostMapping(value = "/rang", produces = "application/json; charset=utf-8")
    public BaseResult coalRecordQuartz(Long coalId) throws Exception {
        BaseResult result=quartzService.updateCoalStatistical(coalId);
       return result;
    }
    @ApiImplicitParam(name = "coalId", value = "商户煤炭id", dataType = "int", required = true, paramType = "query")
    @ApiOperation(value = "根据煤炭id维护同比数据")
    @PostMapping(value = "/same", produces = "application/json; charset=utf-8")
    public BaseResult coalRecorduartz(Long coalId) throws Exception {

       BaseResult result= quartzService.updateCoalSameStatistical(coalId);
       return  result;
    }
    @ApiImplicitParam(name = "coalId", value = "商户煤炭id", dataType = "int", required = true, paramType = "query")
    @ApiOperation(value = "根据煤炭id维护所有")
    @PostMapping(value = "/rang-same", produces = "application/json; charset=utf-8")
    public BaseResult rangSame(@RequestBody Long coalId) throws Exception {
        BaseResult result= quartzService.updateAllStatistical(coalId);
       return  new BaseResult(0,result);
    }

}
